<?php
class SearchModule extends fvModule {

	function __construct () {
	    $moduleName = strtolower(substr(__CLASS__, 0, -6));
	    parent::__construct(fvSite::$fvConfig->get("modules.{$moduleName}.smarty.template"), 
	                        fvSite::$fvConfig->get("modules.{$moduleName}.smarty.compile"), 
	                        fvSite::$Layoult);
	}
	
	function showIndex($params) {
		$request = fvRequest::getInstance();
		$text = $request->getRequestParameter("q");
		if ($text){
			$this->__assign('Faqs', FaqManager::getInstance()->getAll("(answer like '%".mysql_real_escape_string($text) ."%' or question like '%".mysql_real_escape_string($text) ."%') and lang='".fvSite::$fvSession->get("lang")."'", "create_date DESC"));
	        $this->__assign('Presscenter', PresscenterManager::getInstance()->getAll("(title like '%".mysql_real_escape_string($text) ."%' or html like '%".mysql_real_escape_string($text) ."%'  or annotation like '%".mysql_real_escape_string($text) ."%') and lang='".fvSite::$fvSession->get("lang")."'"));
	        $this->__assign('Pages', StaticPagesManager::getInstance()->getAll("(name like '%".mysql_real_escape_string($text) ."%' or content like '%".mysql_real_escape_string($text) ."%') and lang='".fvSite::$fvSession->get("lang")."'"));
		}
        return $this->__display("search_index.tpl");
	}
	
}
?>